package socket.tcp.demo2;

import java.io.DataOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.net.Socket;

/**
 * @author 周宇
 * @create 2020-05-26 14:18
 */
public class ClientDemo {
    public static void main(String[] args) throws IOException {
        //1.创建一个Socket对象
        Socket socket = new Socket("127.0.0.1", 8888);
        //2.获取一个IO流开始写数据
        OutputStream os = new DataOutputStream(socket.getOutputStream());
        os.write("hello".getBytes());
        //3.是否资源
        os.close();
        socket.close();
    }
}
